﻿using System;
using System.Windows;
using System.Windows.Data;
using AutoLoL.Entities;
using System.Linq;

namespace AutoLoL.Converters
{
    public class MasteryToPointsRequiredVisibilityConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Length == 2)
            {
                MasteryValue mastery = values[0] as MasteryValue;
                if (mastery != null)
                {
                    int total = mastery.MasteryTree.MasteryValues.Where(m => m.Row < mastery.Row).Sum(m => m.CurrentRank);

                    if (total < mastery.PointsToActivate)
                    {
                        return Visibility.Visible;
                    }
                }
            }

            return Visibility.Collapsed;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
